﻿/*
Copyright (C) 17/06/2010  Matthew "Scent Tree" Perry
scent.tree@gmail.com

This library/program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This libary/program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.IO;

namespace OblivionTools.OMod
{
	/// <summary>
	/// The OMod metadata
	/// </summary>
	public struct OModConfig
	{
		/// <summary>
		/// The format version
		/// </summary>
		public byte FormatVersion;
		
		/// <summary>
		/// The mod name
		/// </summary>
		public string Name;
		
		/// <summary>
		/// The major version number
		/// </summary>
		public int Major;
		
		/// <summary>
		/// The minor version number
		/// </summary>
		public int Minor;
		
		/// <summary>
		/// The mod author
		/// </summary>
		public string Author;
		
		/// <summary>
		/// The author's email
		/// </summary>
		public string Email;
		
		/// <summary>
		/// The website for the mod
		/// </summary>
		public string Website;
		
		/// <summary>
		/// The mod's description
		/// </summary>
		public string Description;
		
		/// <summary>
		/// The date and time of mod creation
		/// </summary>
		public DateTime CreatedDate;
		
		/// <summary>
		/// The type of compresson used
		/// </summary>
		public byte CompressionType;
		
		/// <summary>
		/// The revision version number
		/// </summary>
		public int Revision;
		
		/// <summary>
		/// Reads metadata from a config formatted file
		/// </summary>
		/// <param name="br">The reader</param>
		public OModConfig(BinaryReader br)
		{
			FormatVersion = br.ReadByte();
			Name = br.ReadString();
			Major = br.ReadInt32();
			Minor = br.ReadInt32();
			Author = br.ReadString();
			Email = br.ReadString();
			Website = br.ReadString();
			Description = br.ReadString();
			CreatedDate = DateTime.FromBinary(br.ReadInt64());
			CompressionType = br.ReadByte();
			Revision = br.ReadInt32();
		}
	}
}
